package com.abe.libphoto;

import java.io.File;

import android.os.Environment;

public class InspectionSDcard {

    /**
     * 返回参数：1-没有储存卡；2-没有找到储存目录;3-成功
     *
     * @param dir d
     */
    public static int isThereSdcard(File dir) {
        // 先验证手机是否有sdcard
        String status = Environment.getExternalStorageState();
        if (status.equals(Environment.MEDIA_MOUNTED)) {
            try {
                if (!dir.exists()) {
                    boolean isSuccess = dir.mkdirs();
                    System.out.println(isSuccess);
                }
            } catch (Exception e) {
                return 2;
            }
            return 3;
        } else {
            return 1;
        }
    }

    public static boolean checkSdcard(File dir) {
        int x = isThereSdcard(dir);
        boolean status = false;
        switch (x) {
            case 3: {
                status = true;
            }
            break;
            default: {
                status = false;
            }
            break;
        }
        return status;
    }
}
